#include <jni.h>
#include "CCRender.h"
//
// Created by Administrator on 2022-12-04.
//

CCRender* ccRender;
extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_openglcamera_render_GLRender_ndkInitGL(JNIEnv *env, jobject thiz,jobject assets) {
    ccRender = new CCRender();
    ccRender->initGL();
    AAssetManager *astManager = AAssetManager_fromJava (env, assets);
    ccRender->ccOpenGlShader.InitShadersFromFile(astManager,"vertex.vert","fragment.frag");
}
extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_openglcamera_render_GLRender_ndkPaintGL(JNIEnv *env, jobject thiz,
                                                           jint texture_id) {
    ccRender->paintGL(texture_id);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_openglcamera_render_GLRender_ndkResizeGL(JNIEnv *env, jobject thiz, jint width,
                                                            jint height) {
    ccRender->resizeGL(width,height);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_itfitness_openglcamera_render_GLRender_ndkRelease(JNIEnv *env, jobject thiz) {
    delete ccRender;
}